<template>
  <div class="container">
    <div style="height: 100px; padding: 25px 25px 0px">
      <el-input
        placeholder="请输入内容"
        v-model="inputName"
        class="input-with-select"
      >
        <el-button slot="append" icon="el-icon-search" @click="searchMeetingRoomList"></el-button>
      </el-input>
    </div>
    <el-row style="padding: 0px 15px 200px">
      <el-col
        :span="11"
        v-for="(item, index) in listData"
        :key="index"
        :offset="index % 2 === 0 ? 1 : 0"
      >
        <el-card
          :body-style="{ padding: '0px' }"
          style="margin: 10px"
          @click.native="selectConferenceRoom(item)"
        >
          <!-- <img
            src="https://img.yaokaihui.com/86195160/366d530d3faa59cf77d8e498fea8faf5.jpg"
            class="image"
          /> -->
          <div>
            <span style="padding: 5px 10px; font-size: 18px !important">{{
              item.会议室名称
            }}</span>
            <p style="padding: 20px 10px; font-size: 15px !important">{{
              item.简介
            }}</p>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  data () {
    return {
      VID: '',
      ClientName: '天津港一公司办公楼',
      inputName: '',
      originalData: null,
      listData: null,
    }
  },
  mounted () {
    this.getMeetingRoomList();
  },
  beforeRouteEnter (to, from, next) {
    if (from.name === "MyReservationList") {
      next((vm) => {
        vm.VID = from.params.VID;
        vm.ClientName = from.params.ClientName;
        vm.getMeetingRoomList()
      })
    }else {
      next((vm) => {
        vm.getMeetingRoomList()
      })
    }
  },
  methods: {
    async getMeetingRoomList () {
      // var url = "ConferenceRoom/GetMeetingRoomList?ClientName=天津港一公司办公楼"
      var url = "ConferenceRoom/GetMeetingRoomList?ClientName=" + this.ClientName
      const { data } = await this.$Http.get(url)
      this.originalData = data
      this.searchMeetingRoomList()
    },
    searchMeetingRoomList () {
      if (this.inputName != '') {
        this.listData = this.originalData.filter(item => item.会议室名称.includes(this.inputName))
      } else {
        this.listData = this.originalData
      }
    },
    selectConferenceRoom (item) {
      this.$route.params.VID = this.VID;
      this.$route.params.cRoom = item;
      this.$router.push({ path: '/ConferenceRoomReservation' })
    },
  }
}
</script>

<style lang="scss" scoped>
.time {
  font-size: 13px;
  color: #999;
}

.bottom {
  margin-top: 13px;
  line-height: 12px;
  font-size: 25px;
}

.button {
  padding: 0;
  float: right;
}

.image {
  width: 100%;
  height: 20%;
  display: block;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: '';
}

.clearfix:after {
  clear: both;
}
.context {
  font-size: 18px !important;
  line-height: 20px !important;
}
</style>
